<?php if (!defined('THINK_PATH')) exit();?><style>
    .nav-pills>li.active>a, .nav-pills>li.active>a:focus, .nav-pills>li.active>a:hover{
        color: inherit;
        background-color: inherit;
    }
</style>
<div class="row">
    <div class="col-md-3">
        <div class="box box-solid">
            <div class="box-header with-border">
                <h3 class="box-title">系统设置</h3>
                <div class="box-tools">
                    <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
                    </button>
                </div>
            </div>
            <div class="box-body no-padding">
                <ul class="nav nav-pills nav-stacked">
                    <li class="active"><a href="#setting_1" data-toggle="tab"><i class="icon iconfont icon-jichushezhi"></i> 基础设置</a></li>
                    <li><a href="#setting_3" data-toggle="tab"><i class="icon iconfont icon-youjian"></i> 短信设置</a></li>
                    <li><a href="#setting_5" data-toggle="tab" style="display: none"><i class="icon iconfont icon-daijinjuan"></i> 代金卷设置</a></li>
                    <li><a href="#setting_6" data-toggle="tab"><i class="icon iconfont icon-tixian"></i> 提现设置</a></li>
                    <li><a href="#setting_9" data-toggle="tab"><i class="icon iconfont icon-chongzhi"></i> 充值设置</a></li>
                    <li><a href="#setting_10" data-toggle="tab"><i class="icon iconfont icon-fan"></i> 经纪人返佣配置</a></li>
                </ul>
            </div>
            <!-- /.box-body -->
        </div>
    </div>
    <!-- /.col -->
    <div class="col-md-9 tab-content">
        <div class="box box-primary tab-pane active" id="setting_1">
            <div class="box-header with-border">
    <h3 class="box-title">基础设置</h3>
    <!-- /.box-tools -->
</div>
<!-- /.box-header -->
<form role="form" onsubmit="return sub_setting_1()">
    <div class="box-body">
        <div class="form-group" style="overflow:hidden;">
            <div style="float:left;margin-right:10px;">
                <label>邀请码状态</label>
                <input type="checkbox" id="invite_code_state" class="on-off-button" data-size="mini" data-label-width="0" data-off-text="关闭" data-on-text="开启" data-handle-width="40" <?php echo ($sys['invite_code_state']==2?'':'checked'); ?>>
            </div>
            <div class="checkbox" id="invite_code_state_other_txt" style="float:left;margin:2px;color:<?php echo ($sys['invite_code_state']==2?'#a7a7a7':'#000000'); ?>"><label><input id="invite_code_state_other" <?php echo ($sys['invite_code_state']==2?'disabled="disabled"':''); ?> <?php echo ($sys['invite_code_state']==3?'checked':''); ?> type="checkbox">是否强制使用邀请码</label></div>
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="exchange_rate">汇率设置<font color="#d63c28">（金额 = 人民币1元 * <?php echo ($sys['exchange_rate']); ?>）</font></label>
            <input type="text" value="<?php echo ($sys['exchange_rate']); ?>" class="form-control" id="exchange_rate" placeholder="汇率设置">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="exchange_rate">倍率设置</label>
            <input type="text" value="<?php echo ($sys['multiplying_power']); ?>" class="form-control" id="multiplying_power" placeholder="倍率设置">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="once_max_order_num">单次下单最大手数</label>
            <input type="text" value="<?php echo ($sys['once_max_order_num']); ?>" class="form-control" id="once_max_order_num" placeholder="单次下单最大手数">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="order_fee">下单手续费(%)</label>
            <input type="text" value="<?php echo ($sys['order_fee']); ?>" class="form-control" id="order_fee" placeholder="下单手续费">
        </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    $(function() {
        $("#invite_code_state").on('switchChange.bootstrapSwitch', function(event, state) {
            if (state == true) {
                $("#invite_code_state_other").removeAttr("disabled");
                $("#invite_code_state_other_txt").css("color", "#000000")
            } else {
                $("#invite_code_state_other").attr("disabled", true);
                $("#invite_code_state_other_txt").css("color", "#a7a7a7")
            }
        });
    });
    function sub_setting_1(){
        var invite_code_state = 1;
        var flag = $("#invite_code_state").bootstrapSwitch("state");
        if (flag == false) {
            invite_code_state = 2;
        } else {
            if($("#invite_code_state_other").is(':checked')) {
                invite_code_state = 3;
            }
        }

        var exchange_rate = $("#exchange_rate").val();
        if (exchange_rate < 0) {
            $.scojs_message("汇率设置不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }

        var multiplying_power = $("#multiplying_power").val();
        if (multiplying_power < 0) {
            $.scojs_message("倍率设置不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }

        var once_max_order_num = $("#once_max_order_num").val();
        if (once_max_order_num < 0) {
            $.scojs_message("单次下单最大手数不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var order_fee = $("#order_fee").val();
        if (order_fee <  0) {
            $.scojs_message("下单手续费不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : 'admin/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                invite_code_state:invite_code_state,
                exchange_rate:exchange_rate,
                multiplying_power:multiplying_power,
                once_max_order_num:once_max_order_num,
                order_fee:order_fee
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }
</script>
        </div>

        <div class="box box-primary tab-pane" id="setting_3">
            <div class="box-header with-border">
    <h3 class="box-title">短信设置</h3>
    <!-- /.box-tools -->
</div>
<!-- /.box-header -->
<form role="form" onsubmit="return sub_setting_3()">
    <div class="box-body">
        <div class="form-group">
            <label for="sms_account">短信平台账号</label>
            <input type="text" class="form-control" value="<?php echo ($sys['sms_account']); ?>" id="sms_account" placeholder="短信平台账号">
        </div>
        <div class="form-group">
            <label for="sms_pwd">短信平台密码</label>
            <input type="text" class="form-control" value="<?php echo ($sys['sms_pwd']); ?>" id="sms_pwd" placeholder="短信平台密码">
        </div>
        <div class="form-group">
            <label for="reg_sms_content">短信内容</label>
            <textarea class="form-control" id="reg_sms_content" rows="3" placeholder="短信内容"><?php echo ($sys['reg_sms_content']); ?></textarea>
        </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    function sub_setting_3(){

        var sms_account = $("#sms_account").val();
        if (sms_account ==  "") {
            $.scojs_message("短信平台账号不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var sms_pwd = $("#sms_pwd").val();
        if (sms_pwd ==  "") {
            $.scojs_message("短信平台密码不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var reg_sms_content = $("#reg_sms_content").val();
        if (reg_sms_content ==  "") {
            $.scojs_message("短信内容不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : 'admin/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                sms_account:sms_account,
                sms_pwd:sms_pwd,
                reg_sms_content:reg_sms_content
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }
</script>
        </div>

        <div class="tab-pane" id="setting_5">
            <style>
    .select2-container--open {
        z-index: 99999999;
    }
</style>
<div class="col-xs-16">
    <div class="nav-tabs-custom">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#setting_5_1" data-toggle="tab">代金卷设置</a></li>
            <li><a id="djj_tab" <?php echo ($sys['is_send_voucher']==2?'href="javascript:void(0)" style="cursor: no-drop;color:#a7a7a7;"':'href="#setting_5_2" data-toggle="tab"'); ?>>新用户送券配置</a></li>
        </ul>
        <div class="tab-content">
            <div class="tab-pane active" id="setting_5_1">
                <form role="form" onsubmit="return sub_setting_5()">
                    <div class="box-body">
                        <div class="form-group">
                            <label>是否启用代金卷</label>
                            <input type="checkbox" id="use_voucher" class="on-off-button" data-size="mini" data-label-width="0" data-off-text="不启用" data-on-text="启用" data-handle-width="40" <?php echo ($sys['use_voucher']==1?'checked':''); ?>>
                            <font color="#AE1F00">(修改后下一轮下单时开始生效)</font>
                        </div>
                        <div class="form-group">
                            <label>新用户注册是否赠送代金劵</label>
                            <input type="checkbox" id="is_send_voucher" class="on-off-button" data-size="mini" data-label-width="0" data-off-text="不赠送" data-on-text="赠送" data-handle-width="40" <?php echo ($sys['is_send_voucher']==1?'checked':''); ?>>
                        </div>
                        <div class="form-group">

                            <div class="box-body table-responsive no-padding">
                                <table class="table table-striped table-hover">
                                    <tbody>
                                        <th>代金劵名称</th>
                                        <th>使用方法</th>
                                        <th>操作</th>
                                        <?php if(is_array($voucher_type_list)): $i = 0; $__LIST__ = $voucher_type_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$voucher_type): $mod = ($i % 2 );++$i;?><tr>
                                                <td><?php echo ($voucher_type["name"]); ?></td>
                                                <td>
                                                    <?php if($voucher_type["type"] == 1): ?>直接使用
                                                        <?php else: ?>
                                                        单注金额达到<?php echo (sprintf('%.2f',$voucher_type['use_money'])); ?>元才能使用<?php endif; ?>
                                                </td>
                                                <td>
                                                    <span class="label label-primary" style="cursor:pointer;margin-right:3px;" onclick="edit_voucher_type_data('<?php echo ($voucher_type["id"]); ?>');">修改</span>
                                                </td>
                                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                                    </tbody>
                                </table>
                            </div>

                        </div>
                    </div>
                    <!-- /.box-body -->

                    <div class="box-footer">
                        <button type="submit" class="btn btn-primary">保存</button>
                    </div>
                </form>
            </div>

            <div class="tab-pane" id="setting_5_2">
                <div class="box">
                    <div class="box-header" style="height:30px;">
                        <div class="box-tools">
                            <div class="input-group input-group-sm">
                                <button type="button" id="daer_djj_setting_btn" class="btn btn-info btn-xs"><i class="fa fa-plus"></i><span style="margin-left:5px;">添加配置</span></button>
                            </div>
                        </div>
                    </div>

                    <div class="box-body table-responsive no-padding">
                        <table class="table table-striped table-hover">
                            <tbody id="row_djj_data">
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer clearfix">
                        <div id="info_voucher_data" class="col-sm-5" style="top:5px;"><div class="dataTables_info" id="example1_info" role="status" aria-live="polite"></div></div>
                        <div class="col-sm-7">
                            <input type="hidden" value="10" id="page_size_voucher_config"/>
                            <input type="hidden" value="1" id="page_num_voucher_config"/>
                            <ul id="paging_voucher" class="pagination pagination-sm no-margin pull-right"></ul>
                        </div>
                    </div>
                    <div class="overlay hidden">
                        <i class="fa fa-refresh fa-spin"></i>
                    </div>
                </div>
            </div>

        </div>
        <!-- /.tab-content -->
    </div>
    <!-- /.nav-tabs-custom -->
</div>

<div id="win_voucher_temp" style="padding:20px;display:none;">
    <form id="daer_voucher_from" onsubmit="return false">
        <input type="hidden" name="id" id="id">
        <div class="form-group">
            <label for="voucher_range">代金券使用范围（不选默认为全场）</label>
            <select id="voucher_range" name="voucher_range" class="form-control select2 select2-hidden-accessible" style="width:100%;" tabindex="-1" aria-hidden="false" multiple="multiple">
                <?php if(is_array($games)): $i = 0; $__LIST__ = $games;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$game): $mod = ($i % 2 );++$i;?><option value="<?php echo ($game["id"]); ?>"><?php echo ($game["game_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
        <div class="form-group">
            <label for="end_price">代金券面额</label>
            <div class="input-group">
                <input type="text" style="ime-mode:disabled;" onpaste="return false;" onkeypress="keyPress()" class="form-control" name="money" value="20" id="money" placeholder="代金券面额">
                <span class="input-group-addon">.00</span>
            </div>
        </div>
        <div class="form-group">
            <label for="type">代金券类型</label>
            <select id="type" name="type" class="form-control select2 select2-hidden-accessible" style="width:100%;" tabindex="-1" aria-hidden="true">
                <?php if(is_array($voucher_type_list)): $i = 0; $__LIST__ = $voucher_type_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$voucher_type): $mod = ($i % 2 );++$i;?><option value="<?php echo ($voucher_type["id"]); ?>"><?php echo ($voucher_type["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
            </select>
        </div>
        <div class="form-group">
            <label for="profit_odds">代金券数量</label>
            <input type="text" style="ime-mode:disabled;" onpaste="return false;" onkeypress="keyPress()" class="form-control" name="voucher_num" id="voucher_num" value="2" placeholder="代金券数量">
        </div>
        <div class="form-group">
            <label for="day_num">有效天数</label>
            <input type="text" style="ime-mode:disabled;" onpaste="return false;" onkeypress="keyPress()" class="form-control" name="day_num" id="day_num" value="3" placeholder="有效天数">
        </div>
    </form>
</div>

<script>
    $(function () {
        $(".select2").select2({minimumResultsForSearch: Infinity});
        $("#use_voucher").on('switchChange.bootstrapSwitch', function(event, state) {
            var use_voucher = 1;
            var info = '代金劵已启用';
            if (state == true) {
                use_voucher = 1;
                info = '代金劵已启用';
                $("#voucher_use_money").removeAttr("disabled");
                $("#voucher_use_money_txt").css("color", "#333333");
                $("#max_use_voucher_count").removeAttr("disabled");
                $("#max_use_voucher_count_txt").css("color", "#333333");
                // data-toggle="tab"
            } else {
                use_voucher = 2;
                info = '代金劵已停用';
                $("#voucher_use_money").attr("disabled", true);
                $("#voucher_use_money_txt").css("color", "#a7a7a7");
                $("#max_use_voucher_count").attr("disabled", true);
                $("#max_use_voucher_count_txt").css("color", "#a7a7a7");
            }

            $.ajax({
                type:"POST",
                url : 'admin/'+moduleName+'/setting',
                dataType:"json",
                data:{
                    id:1,
                    use_voucher:use_voucher
                },
                beforeSend:showLoad,
                success:function(msg) {
                    if (msg.code == 0)
                        $.scojs_message(info, $.scojs_message.TYPE_OK);
                    else
                        $.scojs_message('代金劵启用&停用失败', $.scojs_message.TYPE_ERROR);
                    hideLoad();
                }
            });

        });

        $("#is_send_voucher").on('switchChange.bootstrapSwitch', function(event, state) {
            var is_send_voucher = 1;
            var info = '开启新用户注册赠送代金劵功能';
            if (state == true) {
                is_send_voucher = 1;
                info = '开启新用户注册赠送代金劵功能';
                $("#djj_tab").css({cursor:"pointer",color:"#444444"}).attr({href:"#setting_5_2", "data-toggle":"tab"});
            } else {
                is_send_voucher = 2;
                info = '关闭新用户注册赠送代金劵功能';
                $("#djj_tab").css({cursor:"no-drop",color:"#a7a7a7"}).attr({href:"javascript:void(0)"}).removeAttr("data-toggle");
            }
            $.ajax({
                type:"POST",
                url : 'admin/'+moduleName+'/setting',
                dataType:"json",
                data:{
                    id:1,
                    is_send_voucher:is_send_voucher
                },
                beforeSend:showLoad,
                success:function(msg) {
                    if (msg.code == 0)
                        $.scojs_message(info, $.scojs_message.TYPE_OK);
                    else
                        $.scojs_message('新用户注册赠送代金劵开启&关闭失败', $.scojs_message.TYPE_ERROR);
                    hideLoad();
                }
            });
        });

        $("#djj_tab").on("click", function () {
            if($(this).attr("data-toggle")) {
                loadVoucherData()
            }
        });
        $("#fl_djj_tab").on("click", function () {
            if($(this).attr("data-toggle")) {
                loadVoucherData()
            }
        });
        $("#daer_djj_setting_btn").on("click", function () {
            open_voucher_win_from("添加配置", 0, "", "", "", "", "")
        });
    });

    //加载数据
    function loadVoucherData() {
        showLoad();
        $.ajax({
            type : "post",
            url : 'admin/userVoucher/tolist',
            dataType:"json",
            data: {
                page_num : $('#page_num_voucher_config').val()
                ,page_size : $('#page_size_voucher_config').val()
                //多条件查询在此添加提交数据
            },
            success : function(msg) {
                showVoucherData(msg);
                paging_handler(msg, "paging_voucher", "info_voucher_data", "showVoucherPage");
                hideLoad();
            }
        });
    }

    //根据页码显示数据
    function showVoucherPage(pageNum) {
        $('#page_num_voucher_config').val(pageNum);
        loadVoucherData();
    }

    //数据拼装
    function showVoucherData(msg) {
        var content = '';
        //datatable head
        content += '<tr>';
        content += '<th style="width:35px;">#</th>';
        content += '<th>代金券使用范围</th>';
        content += '<th>代金券面额</th>';
        content += '<th>代金券类型</th>';
        content += '<th>代金券数量</th>';
        content += '<th>有效天数</th>';
        content += '<th style="width:130px;">操作</th>';
        content += '</tr>';

        //datatable data
        for (var i = 0; i < msg.list.length; i++) {
            var voucher_range = "全场";
            if (null != msg.list[i].voucher_range && msg.list[i].voucher_range != "") {
                voucher_range = msg.list[i].voucher_range;
            }
            content += '<tr>';
            content += '<td>' + (i+1) + '</td>';
            content += '<td>' + voucher_range + '</td>';
            content += '<td>' + msg.list[i].money + '</td>';
            content += '<td>' + msg.list[i].type + '</td>';
            content += '<td>' + msg.list[i].voucher_num + '</td>';
            content += '<td>' + msg.list[i].day_num + '</td>';
            content += '<td>';
            content += '<span class="label label-primary" style="cursor:pointer;margin-right:3px;" onclick="edit_voucher_data(' + msg.list[i].id + ');">修改</span>';
            content += '<span class="label label-warning" style="cursor:pointer;margin-right:3px;" onclick="delete_voucher_data(this,' + msg.list[i].id + ');">删除</span>';
            content += '</td>';
            content += '</tr>';
        }
        $('#row_djj_data').html(content);
    }

    function delete_voucher_data(obj, id) {
        //询问框
        layer.confirm('您确认要删除该数据吗？', {
            btn: ['确认','取消'] //按钮
        }, function(index){
            showLoad();
            $.ajax({
                type : "post",
                url : 'admin/userVoucher/delete',
                dataType:"json",
                data: {
                    id : id
                },
                success : function(msg) {
                    //alert(msg.code);
                    if (msg.code == 0) {
                        $(obj).parent().parent().fadeOut("slow");
                        //layer.msg('删除成功');
                        $.scojs_message('删除成功', $.scojs_message.TYPE_OK);
                    } else {
                        //layer.msg('删除失败');
                        $.scojs_message('删除失败', $.scojs_message.TYPE_ERROR);
                    }
                    hideLoad();
                }
            });

            layer.close(index);
        }, function(){
        });
    }

    function edit_voucher_data(id) {
        $.ajax({
            type : "post",
            url : 'admin/userVoucher/get_data',
            dataType:"json",
            data: {
                id : id
            },
            success : function(msg) {
                open_voucher_win_from("修改配置", msg.data.id, msg.data.voucher_range,msg.data.money,msg.data.type,msg.data.voucher_num,msg.data.day_num);
            }
        });
    }

    function open_voucher_win_from(title, id, voucher_range, money, type, voucher_num, day_num) {
        var load = null;
        layer.open({
            type: 1,
            anim:3,
            title: title,
            area: '500px',
            content: $("#win_voucher_temp"),
            btn: ['保存'],
            success: function () {
                var voucher_range_arr = [];
                if (null != voucher_range && voucher_range != "" && voucher_range != 0) {
                    voucher_range_arr = voucher_range.split(',');
                } else if (id > 0) {
                    $("#voucher_range option").each(function (){
                        voucher_range_arr.push($(this).attr("value"));
                    });
                }
                $("#voucher_range").val(voucher_range_arr).trigger('change');

                $("#id").val(id);
                $("#money").val(money);
                $("#type").val(type);
                $("#voucher_num").val(voucher_num);
                $("#day_num").val(day_num);

            },
            yes: function(index, layero){
                //按钮【按钮一】的回调
                var d = {};
                var t = $('#daer_voucher_from').serializeArray();
                $.each(t, function() {
                    d[this.name] = this.value;
                });
                if (null != $("#voucher_range").val() && "" != $("#voucher_range").val()) {
                    d["voucher_range"] = $("#voucher_range").val();
                }
                $.ajax({
                    type:"POST",
                    url : 'admin/userVoucher/addoreditbigtradeconfig',
                    dataType:"json",
                    data:d,
                    beforeSend:function () {
                        load = layer.load();
                    },
                    success:function(msg) {
                        loadVoucherData();
                        layer.close(load);
                        layer.alert(msg.msg);
                        if (msg.code == 0)
                            layer.close(index);
                    }
                });
            },
            cancel: function(index, layero){
                $("#voucher_range option").each(function (){
                    $(this).removeAttr("selected");
                });
            }
        });
    }
    
    function edit_voucher_type_data(id) {
        $.ajax({
            type : "post",
            url : 'admin/voucherType/get_data',
            dataType:"json",
            data: {
                id : id
            },
            success : function(msg) {
                var html = '<form id="daer_voucher_type_from" onsubmit="return false">';
                html += '<input type="hidden" name="id" id="id" value="'+id+'">';
                html += '<div class="form-group">';
                html += '<label for="start_price">代金劵类型名称</label>';
                html += '<input type="text" class="form-control" name="name" id="name" value="'+msg.data.name+'" placeholder="代金劵类型名称">';
                html += '</div>';
                html += '<div class="form-group">';
                html += '<label>代金券使用类型</label>';
                // html += '<input type="text" class="form-control" name="money" id="money" value="'+msg.data.type+'" placeholder="代金券使用类型">';
                var direct_use = '';
                var condition_use = '';
                var use_money_use = '';
                if (msg.data.type == 1) {
                    direct_use = 'checked';
                    use_money_use = 'disabled';
                } else if (msg.data.type == 2) {
                    condition_use = 'checked';
                }
                html += '<div class="input-group">';
                html += '<div class="radio"> <label for="direct_use"><input type="radio" id="direct_use" value="1" name="type" '+direct_use+'>直接使用</label></div>';
                html += '<div class="radio"> ';
                html += '<label for="condition_use"><input type="radio" id="condition_use" value="2" name="type" style="float:left;display:block;margin-top:10px;" '+condition_use+'>';
                html += '<span style="float:left;line-height:33px">单注金额达到</span>';
                html += '<input type="text" style="float:left;width:30%;margin-left:10px;margin-right:10px;" '+use_money_use+' class="form-control" name="use_money" id="use_money" value="'+msg.data.use_money+'" placeholder="代金劵类型名称">';
                html += '<span style="float:left;line-height:33px">元才能使用</span></label>';
                html += '</div>';
                html += '</div>';
                html += '</div>';
                html += '</form>';
                var load = null;
                layer.open({
                    anim:3,
                    title: "修改代金劵",
                    area: '500px',
                    content: html,
                    btn: ['保存'],
                    success:function () {
                        $(":radio").click(function(){
                            if ($(this).val() == 1) {
                                $("#use_money").attr("disabled", true);
                            } else {
                                $("#use_money").removeAttr("disabled");
                            }
                        });
                    },
                    yes: function(index, layero){
                        //按钮【按钮一】的回调
                        var d = {};
                        var t = $('#daer_voucher_type_from').serializeArray();
                        $.each(t, function() {
                            d[this.name] = this.value;
                        });
                        $.ajax({
                            type:"POST",
                            url : 'admin/voucherType/addoreditbigtradeconfig',
                            dataType:"json",
                            data:d,
                            beforeSend:function () {
                                load = layer.load();
                            },
                            success:function(msg) {
                                layer.close(load);
                                layer.alert(msg.msg);
                                if (msg.code == 0)
                                    layer.close(index);
                            }
                        });
                    }
                });

                // open_voucher_win_from("修改配置", msg.data.id, msg.data.voucher_range,msg.data.money,msg.data.type,msg.data.voucher_num,msg.data.day_num);
            }
        });
    }

    function sub_setting_5(){
        var voucher_use_money = $("#voucher_use_money").val();
        if (voucher_use_money ==  "") {
            $.scojs_message("代金券使用金额不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var max_use_voucher_count = $("#max_use_voucher_count").val();
        if (max_use_voucher_count ==  "") {
            $.scojs_message("免费使用代金券次数不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : 'admin/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                voucher_use_money:voucher_use_money,
                max_use_voucher_count:max_use_voucher_count
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }

    function keyPress() {
        var keyCode = event.keyCode;
        if ((keyCode >= 48 && keyCode <= 57)) {
            event.returnValue = true;
        } else {
            event.returnValue = false;
        }
    }
</script>
        </div>

        <div class="box box-primary tab-pane" id="setting_6">
            <div class="box-header with-border">
    <h3 class="box-title">提现设置</h3>
    <!-- /.box-tools -->
</div>
<!-- /.box-header -->

<form role="form" onsubmit="return sub_setting_6()">
    <div class="box-body">
        <div class="form-group">
            <label for="withdrawals_fee">提现手续费</label>
            <input type="text" class="form-control" value="<?php echo ($sys['withdrawals_fee']); ?>" id="withdrawals_fee" placeholder="提现手续费">
        </div>
        <div class="form-group">
            <label for="lowest_money">最低提现金额</label>
            <input type="text" class="form-control" value="<?php echo ($sys['lowest_money']); ?>" id="lowest_money" placeholder="最低提现金额">
        </div>
        <div class="form-group">
            <label for="highest_money">最大提现金额</label>
            <input type="text" class="form-control" value="<?php echo ($sys['highest_money']); ?>" id="highest_money" placeholder="最大提现金额">
        </div>
        <div class="form-group">
            <label for="max_extract_count">每日提现次数</label>
            <input type="text" class="form-control" value="<?php echo ($sys['max_extract_count']); ?>" id="max_extract_count" placeholder="每日提现次数">
        </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    function sub_setting_6(){
        var withdrawals_fee = $("#withdrawals_fee").val();
        if (withdrawals_fee == "") {
            $.scojs_message("提现手续费不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var lowest_money = $("#lowest_money").val();
        if (lowest_money ==  "") {
            $.scojs_message("最低提现金额不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var highest_money = $("#highest_money").val();
        if (highest_money ==  "") {
            $.scojs_message("最大提现金额不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var max_extract_count = $("#max_extract_count").val();
        if (max_extract_count ==  "") {
            $.scojs_message("每日提现次数不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : 'admin/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                withdrawals_fee:withdrawals_fee,
                lowest_money:lowest_money,
                highest_money:highest_money,
                max_extract_count:max_extract_count
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }
</script>
        </div>

        <div class="box box-primary tab-pane" id="setting_9">
            <div class="box-header with-border">
    <h3 class="box-title">充值设置</h3>
    <!-- /.box-tools -->
</div>
<!-- /.box-header -->
<form role="form" onsubmit="return sub_setting_9()">
    <div class="box-body">
        <div class="form-group" style="overflow:hidden;">
            <label for="recharge_fee">充值手续费(%)</label>
            <input type="text" value="<?php echo ($sys['recharge_fee']); ?>" class="form-control" id="recharge_fee" placeholder="充值手续费">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="lowest_recharge">最低充值金额</label>
            <input type="text" value="<?php echo ($sys['lowest_recharge']); ?>" class="form-control" id="lowest_recharge" placeholder="最低充值金额">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="lowest_recharge">最高充值金额</label>
            <input type="text" value="<?php echo ($sys['highest_recharge']); ?>" class="form-control" id="highest_recharge" placeholder="最低充值金额">
        </div>
        <div class="form-group" style="overflow:hidden;">
            <label for="lowest_recharge">每日最充值上限</label>
            <input type="text" value="<?php echo ($sys['day_max_recharge']); ?>" class="form-control" id="day_max_recharge" placeholder="最低充值金额">
        </div>
    </div>
    <!-- /.box-body -->

    <div class="box-footer">
        <button type="submit" class="btn btn-primary">保存</button>
    </div>
</form>

<script>
    function sub_setting_9(){
        var recharge_fee = $("#recharge_fee").val();
        if (recharge_fee ==  "") {
            $.scojs_message("充值手续费不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }

        var lowest_recharge = $("#lowest_recharge").val();
        if (lowest_recharge ==  "") {
            $.scojs_message("最低充值金额不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var highest_recharge = $("#highest_recharge").val();
        if (highest_recharge ==  "") {
            $.scojs_message("最高充值金额不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        var day_max_recharge = $("#day_max_recharge").val();
        if (day_max_recharge ==  "") {
            $.scojs_message("每日最充值上限不能为空", $.scojs_message.TYPE_ERROR);
            return false;
        }
        $.ajax({
            type:"POST",
            url : 'admin/'+moduleName+'/setting',
            dataType:"json",
            data:{
                id:1,
                lowest_recharge:lowest_recharge,
                highest_recharge:highest_recharge,
                day_max_recharge:day_max_recharge,
                recharge_fee:recharge_fee
            },
            beforeSend:showLoad,
            success:function(msg) {
                if (msg.code == 0)
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_OK);
                else
                    $.scojs_message(msg.msg, $.scojs_message.TYPE_ERROR);
                hideLoad();
            }
        });

        return false;
    }
</script>
        </div>

        <div class="box box-primary tab-pane" id="setting_10">
            
<div class="box-header with-border">
    <h3 class="box-title">返利配置</h3>
    <!-- /.box-tools -->
</div>

<div class="box" style="border:0px;">
    <div class="box-body table-responsive">
        <table class="table table-striped table-hover">
            <tbody id="row_rebate_ratio_data">
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="overlay hidden">
        <i class="fa fa-refresh fa-spin"></i>
    </div>
</div>

<script>

    loadRebateRatioData();
    //加载数据
    function loadRebateRatioData() {
        showLoad();
        $.ajax({
            type : "get",
            url : 'admin/RebateRatio/tolist',
            dataType:"json",
            success : function(msg) {
                hideLoad();
                showRebateRatioData(msg);
            }
        });
    }

    //数据拼装
    function showRebateRatioData(msg) {
        var rebate_layer = '2';
        var rebate_layer_alias = '第二经纪人,第一经纪人';
        if (null == rebate_layer_alias && rebate_layer_alias == "") {
            rebate_layer_alias = "";
            for (var i=0; i<rebate_layer.length; i++) {
                if (i>0) {
                    rebate_layer_alias += ",";
                }
                rebate_layer_alias += "第"+(i+1)+"层"
            }
        }

        var content = '';
        //datatable head
        content += '<tr>';
        content += '<th style="width:35px;">#</th>';
        content += '<th>货币</th>';
        content += '<th>返利比例(%)</th>';
        /*for (var i=0; i<rebate_layer; i++) {
            content += '<th>第'+(i+1)+'层返利比例</th>';
        }*/
        content += '<th style="width:130px;">操作</th>';
        content += '</tr>';

        //datatable data
        for (var i = 0; i < msg.data.length; i++) {
            content += '<tr>';
            content += '<td>' + (i+1) + '</td>';
            content += '<td>' + msg.data[i].show_name + '</td>';
            content += '<td>' + msg.data[i].rebate_ratio + '</td>';

            content += '<td>';
            content += '<span class="label label-primary" style="cursor:pointer;margin-right:3px;" onclick="edit_rebate_ratio_data(\'' + msg.data[i].id + '\');">修改</span>';
            content += '</td>';
            content += '</tr>';
        }
        $('#row_rebate_ratio_data').html(content);
    }

    function edit_rebate_ratio_data(play_type) {
        $.ajax({
            type : "post",
            url : 'admin/RebateRatio/get_data',
            dataType:"json",
            data: {
                play_type : play_type
            },
            success : function(msg) {
                open_rebate_ratio_win_from("修改配置", msg.data, play_type);
            }
        });
    }

    function open_rebate_ratio_win_from(title, rebate, play_type) {
        var html = '<form id="daer_rebate_ratio_from" onsubmit="return false">';
        html += '<input type="hidden" class="form-control" name="play_type" id="play_type" value="'+play_type+'">';
        for (var i=0; i<rebate.length; i++) {
            html += '<div class="form-group">';
            html += '<label for="rebate_ratio">第'+rebate[i].rebate_level+'经纪人</label>';
            html += '<input type="text" class="form-control" name="rebate_ratio[]" id="rebate_ratio" value="'+rebate[i].rebate_ratio+'" placeholder="返利比例">';
            html += '</div>';
        }
        html += '</form>';
        var load = null;
        layer.open({
            anim:3,
            title: title,
            area: '500px',
            content: html,
            btn: ['保存'],
            yes: function(index, layero){
                //按钮【按钮一】的回调
                var d = $('#daer_rebate_ratio_from').serializeArray();
                $.ajax({
                    type:"POST",
                    url : 'admin/RebateRatio/addoreditbigtradeconfig',
                    dataType:"json",
                    data:d,
                    beforeSend:function () {
                        load = layer.load();
                    },
                    success:function(msg) {
                        loadRebateRatioData();
                        layer.close(load);
                        layer.alert(msg.msg);
                        if (msg.code == 0)
                            layer.close(index);
                    }
                });
            }
        });
    }
</script>
        </div>

        <!-- /. box -->
    </div>
    <!-- /.col -->

</div>
<!-- /.row -->

<script>
    var moduleName = 'sys';
    $(function(){
        $(".on-off-button").bootstrapSwitch();
    });
</script>